#include<iostream>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
LL s[N];
string s1, s2, s3[N];
int n;
int main()
{
	cin >> n;
	cin >> s1 >> s2;
	bool flag = 0;
	for (int i = 0; i < n; i++) {
		if (s2[i] == 'A' || s2[i] == 'C' || s2[i] == 'M') {
			cout << s1[i];
			flag = 1;
		}
		else {
			if (flag) {
				flag = 0;
				cout << " ";
			}
		}
	}
	return 0;
}